package com.tmall.wireless.virtualviewdemo.utils.imageloader.core.assist;

import ohos.agp.components.Image;

public enum ViewScaleType {
    /**
     * Scale the image uniformly (maintain the image's aspect ratio) so that at least one dimension (width or height) of
     * the image will be equal to or less the corresponding dimension of the view.
     */
    FIT_INSIDE,
    /**
     * Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the
     * image will be equal to or larger than the corresponding dimension of the view.
     */
    CROP;


    public static ViewScaleType fromImageView(Image imageView) {
        switch (imageView.getScaleMode()) {
            case ZOOM_CENTER:
            case INSIDE:
            case ZOOM_START:
            case ZOOM_END:
            case CLIP_CENTER:
                return FIT_INSIDE;
            case STRETCH:
            case CENTER:
            default:
                return CROP;
        }
    }
}
